<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 *
 * @author Joker
 * `notification_id` int(11) NOT NULL,
	`data` text DEFAULT NULL,
	`recipient_uid` int(11) NOT NULL,
	`sender_uid` int(11) NOT NULL,      
 */
class NotificationData extends Model
{
    protected $table="notification_data";
    
    protected $primaryKey = 'id';
    
    protected $fillable = ['id','notification_id','data','recipient_uid','sender_uid','created_at'];
    
    public $timestamps = false;
    
    /**
     * 一对一获取用户信息 发送者
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function sender()
    {
        return $this->hasOne('App\User','id','sender_uid');    
    }
    
    /**
     * 一对一获取用户信息 接受者
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function recipient()
    {
        return $this->hasOne('App\User','id','recipient_uid');
    }
    
    public function notification()
    {
        return $this->belongsTo('App\Models\Notification');
    }
    
}